package com.xuhf.filter;

import com.xuhf.config.Config;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

public class Producer01 {
    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer(Config.PRODUCER_GROUP);
        producer.setNamesrvAddr(Config.NAMESRV_ADDR);
        producer.start();
        String[] tags = {"tagA", "tagB", "tagC", "tagD"};
        for (int i = 100; i < 200; i++) {
            Message message = new Message("07-filter", tags[i % tags.length], ("hello " + i).getBytes());
            SendResult sendResult = producer.send(message);
            System.out.println("生产者发送消息：" + sendResult.getMsgId() + "，发送状态：" + sendResult.getSendStatus());
        }
        producer.shutdown();
    }
}
